//
//  SHMenuRootViewController.m
//  吃货·上海
//
//  Created by lanou on 15/11/24.
//  Copyright © 2015年 濮亚军. All rights reserved.
//

#import "SHMenuRootViewController.h"
#import "SHMenuCollectionController.h"
#import "SHMenuController.h"


@interface SHMenuRootViewController ()

@property(nonatomic,strong)SHMenuCollectionController *collectionVc;
@property(nonatomic,strong)SHMenuController *MenuVc;

//点击瀑布流按钮的状态
@property(nonatomic,assign)BOOL isSelect;

@end

@implementation SHMenuRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //瀑布流按钮
    UIBarButtonItem *rightBarBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"jump"]] style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButton)];
    self.navigationItem.rightBarButtonItem = rightBarBtn;
    
    self.navigationController.navigationBar.translucent =NO;
    
    self.view.backgroundColor = KMyColor;
    
    self.collectionVc =[[SHMenuCollectionController alloc]init];
    self.MenuVc =[[SHMenuController alloc]init];
    
    [self.view addSubview:_collectionVc.view];
    [self.view addSubview:_MenuVc.view];
    
    [self addChildViewController:_collectionVc];
    [self addChildViewController:_MenuVc];

}


#pragma mark - 瀑布流
- (void)rightBarButton
{
    self.isSelect = !_isSelect;
    
    if (self.isSelect) {
        
        [self.navigationItem.rightBarButtonItem setImage:[UIImage imageNamed:@"back_jump"]];
        
        [UIView transitionFromView:self.MenuVc.view toView:self.collectionVc.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
        if (finished) {
            
            
          }
        }];
    }
    else
    {
        [self.navigationItem.rightBarButtonItem setImage:[UIImage imageNamed:@"jump"]];
        
        [UIView transitionFromView:self.collectionVc.view toView:self.MenuVc.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
            if (finished) {
                
                
            }
        }];
    }
}

#pragma mark - 瀑布流按钮
- (void)rightBarButtonItem
{
    UIViewController *vc = self.navigationController.childViewControllers[0];
    [UIView transitionFromView:self.view toView:vc.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
        if (finished) {
            nil;
        }
    }];
    
}


@end
